
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        // banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'Public/static/common/*.js',
        dest: 'build/<%= pkg.name %>.min.js'
      }
    },
    concat : {
      css : {
          src: ['Public/static/mobile/css/bootstrap.min.css',
              'Public/static/mobile/css/non-responsive.css',
              'Public/static/mobile/css/jquery.Jcrop.min.css',
              'Public/static/mobile/css/rater.css',
              'Public/static/mobile/css/style.css'],
          dest:'Public/static/build/css/<%= pkg.name %>.css'
      },
      js : {
          src: ['Public/static/common/jquery-1.9.1.min.js',
              'Public/static/common/angular-1.0.1.min.js',
              'Public/static/common/jquery-ui-1.10.3.custom.min.js',
              'Public/static/common/jquery.ui.touch-punch.min.js',
              'Public/static/common/bootstrap/js/bootstrap.min.js',
              'Public/static/mobile/js/app.js',
              'Public/static/mobile/js/controller.js'],
          dest:'Public/static/build/js/<%= pkg.name %>.js'
      }
    },
    cssmin: {
      css: {
         src:'Public/static/build/css/<%= pkg.name %>.css',
         dest:'Public/static/build/css/<%= pkg.name %>.min.css'
      }
    },
    hash: {
        options: {
            mapping: 'assets.json', //mapping file so your server can serve the right files 
            // srcBasePath: 'App/Home/View/Common/', // the base Path you want to remove from the `key` string in the mapping file 
            // destBasePath: 'App/Home/View/Common/', // the base Path you want to remove from the `value` string in the mapping file 
            flatten: false, // Set to true if you don't want to keep folder structure in the `key` value in the mapping file 
            hashLength: 8, // hash length, the max value depends on your hash function 
            hashFunction: function(source, encoding){ // default is md5 
                return require('crypto').createHash('sha1').update(source, encoding).digest('hex');
            }
        },
        js: {
            src: 'Public/static/build/js/<%= pkg.name %>.js',  //all your js that needs a hash appended to it
            dest: 'Public/static/build/js/' //where the new files will be created
        },
        css: {
            src: 'Public/static/build/css/<%= pkg.name %>.min.css',  //all your css that needs a hash appended to it
            dest: 'Public/static/build/css/' //where the new files will be created
        }
    }
     
  });

  // Load the plugin that provides the "uglify" task.
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-css');
  grunt.loadNpmTasks('grunt-hash');

  // Default task(s).
  grunt.registerTask('default', ['concat', 'cssmin', 'hash']);

};
